package com.natasa.monitor.service;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.stereotype.Component;

/**
 * 任务处理类工厂
 * @author jianfeihit
 *
 */
@Component(value="taskFactory")
public class TaskFactory implements BeanFactoryAware{
    private BeanFactory beanFactory;
    
    public AbstractMonitorTask getTaskHandler(String beanName){
        return (AbstractMonitorTask) this.beanFactory.getBean(beanName);
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        this.beanFactory = beanFactory;
    }
}
